﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_PERMISSION.Base;

namespace ERP_RORZE_PRODUCT.Product.WTS
{
    public partial class frm_DataTranfer : DevExpress.XtraEditors.XtraForm
    {
        ClsWTSDAO clsWTSDAO = new ClsWTSDAO();
        private LogUtils log;

        public frm_DataTranfer()
        {
            InitializeComponent();
            log = new LogUtils();
        }

        private void btnLaborMachine_Click(object sender, EventArgs e)
        {

            //MessageBox.Show("Bạn muốn nhập hết tất cả Labor WTS không?",
            //    "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            clsWTSDAO.TranferLaborToMachine(dateFrom.Value.Date, dateTo.Value.Date);
            clsWTSDAO.UpdateTranferMachineToLabor(dateFrom.Value.Date, dateTo.Value.Date);

            //write Log
            log.Table = LogConstant.Table.Product.MachineWTS;
            log.Task = LogConstant.Task.Transfer;
            log.Description = "Transfer data from LaborWTS: from " + dateFrom.Value.Date.ToShortDateString() + " to " + dateTo.Value.Date.ToShortDateString();
            log.WriteLog();

            MessageBox.Show("Đã chuyển dữ liệu từ Labor sang Machine thành công");
        }

        private void btnMachineLabor_Click(object sender, EventArgs e)
        {
            clsWTSDAO.TranferMachineToLabor(dateFrom.Value.Date, dateTo.Value.Date);
            clsWTSDAO.UpdateTranferLaborToMachine(dateFrom.Value.Date, dateTo.Value.Date);

            //write Log
            log.Table = LogConstant.Table.Product.LaborWTS;
            log.Task = LogConstant.Task.Transfer;
            log.Description = "Transfer data from MachineWTS: from " + dateFrom.Value.Date.ToShortDateString() + " to " + dateTo.Value.Date.ToShortDateString();
            log.WriteLog();

            MessageBox.Show("Đã chuyển dữ liệu từ Machine sang Labor thành công");
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}